public class Main {
    public static void main1(String[] args) {
        //1、==比较是否引用同一个对象
        String str1 = new String("abcd");
        String str2 = new String("hello");
        String str3 = str1;

        System.out.println(str1 == str2);
        System.out.println(str1 == str3);

    }

    public static void main2(String[] args) {
        String str1 = new String("abcd");
        String str2 = new String("hello");
        String str3 = new String("hello");
        System.out.println(str1.equals(str3));
        System.out.println(str2.equals(str3));
    }

    public static void main(String[] args) {
        String str1 = new String("abc");
        String str2 = new String("ac");
        String str3 = new String("abc");
        String str4 = new String("abcdef");

        System.out.println(str1.compareTo(str2));
        System.out.println(str1.compareTo(str3));
        System.out.println(str1.compareTo(str4));
    }
}
